package com.test.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.test.web.entity.User;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class LoginController {
	
	@RequestMapping("/common/login0")
	public String login0(String uname,String pwd){
		return uname+"--->"+pwd;
	}
	@RequestMapping("/common/login1")
	public String login1(@RequestParam("uname") String username,@RequestParam("pwd") String password){
		return username+"--->"+password;
	}
	
	
	@RequestMapping("/common/login2")
	public String login2(User user){
		return user.getUsername()+"--->"+user.getPassword();
	}
	
	@RequestMapping("/common/login3")
	public JSONObject login3(User user){
		JSONObject json=new JSONObject();
		json.put("username", user.getUsername());
		json.put("password", user.getPassword());
		return json;
	}
	
	@RequestMapping("/common/login4/{uname}/{pwd}")
	public String login4(@PathVariable("uname") String username,@PathVariable("pwd") String password){
		return username+"--->"+password;
	}
	
	@RequestMapping("/common/login5/{uname}/{pwd}")
	public String login4(@PathVariable Map param){
		return param.toString();
	}
}
